package com.hq.fxh.No6UerSpace.Activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.hq.fxh.No0_ChengQu.Activity.BaseActivity;
import com.hq.fxh.No5_User.User.Fragment.Fragment_GuanZhu_People;
import com.hq.fxh.No5_User.User.Fragment.Fragment_GuanZhu_Plate;
import com.hq.fxh.No6UerSpace.Adapter.Padpter_Space;
import com.hq.fxh.R;

import java.util.Arrays;

public class SpaceGuanZhuActivity extends BaseActivity implements Padpter_Space.TabPagerListener, View.OnClickListener {

    protected TabLayout tablayoutSpaceGuanzhu;
    protected ViewPager viewPagerSpaceGuanzhu;
    protected ImageView back;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_space_guan_zhu;
    }

    @Override
    protected void initView() {
        tablayoutSpaceGuanzhu = (TabLayout) findViewById(R.id.tablayout_space_guanzhu);
        viewPagerSpaceGuanzhu = (ViewPager) findViewById(R.id.viewPager_space_guanzhu);
        back = (ImageView) findViewById(R.id.back);
        back.setOnClickListener(SpaceGuanZhuActivity.this);
    }

    @Override
    protected void initData() {
        int type = getIntent().getIntExtra("type", 0);

        Padpter_Space adapter = new Padpter_Space(getSupportFragmentManager()
                , 3, Arrays.asList("用户", "板块", "粉丝"), this);
        adapter.setListener(this);
        viewPagerSpaceGuanzhu.setAdapter(adapter);
        adapter.setListener(this);
        viewPagerSpaceGuanzhu.setAdapter(adapter);
        tablayoutSpaceGuanzhu.setupWithViewPager(viewPagerSpaceGuanzhu);
        tablayoutSpaceGuanzhu.setTabMode(TabLayout.MODE_FIXED);

/*
        tablayoutSpaceGuanzhu.setSelectedTabIndicatorColor(type);
*/

    }

    @Override
    public Fragment getFragment(int position) {
        switch (position) {
            case 0:
                return new Fragment_GuanZhu_People();

            case 1:
                return new Fragment_GuanZhu_Plate();

            case 2:
                return new Fragment_GuanZhu_People();

        }
        return null;
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.back) {
            finish();

        }
    }
}
